<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <title>天天生鲜-首页</title>
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <!-- 引入组件库 -->
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
    <link rel="stylesheet" type="text/css" href="css/reset.css">
    <link rel="stylesheet" type="text/css" href="css/main.css">
    <script type="text/javascript" src="js/jquery-1.12.4.min.js"></script>
    <script type="text/javascript" src="js/jquery-ui.min.js"></script>
    <script type="text/javascript" src="js/slide.js"></script>

</head>
<body style="background: linear-gradient(45deg,lightblue,lightgray);">
<div id="app">
    <div class="header_con">
        <div class="header">
            <div class="welcome fl">欢迎来到菜先生!
                <a @click="goBack()" style="cursor: pointer;">返回首页</a>
            </div>
            <div class="fr">
                <!--<div class="login_info fl">
                    欢迎您：<em>张 山</em>

                </div>-->
                <div class="login_btn fl">
                    <a @click="userLogin()">登录</a>
                    <span>|</span>
                    <a @click="userRegister()">注册</a>
                </div>
                <div class="user_link fl">
                    <span>|</span>
                    <a @click="business()">商家中心</a>
                    <span>|</span>
                    <a @click="message()">消息中心</a>
                    <span>|</span>
                    <a @click="isLogin()">用户中心</a>
                    <span>|</span>
                    <a @click="myShop()">我的购物车</a>
                    <span>|</span>
                    <a @click="myOrder()">我的订单</a>
                </div>
            </div>
        </div>
    </div>


        <div class="jumbotron" style="width: 100%;height: 200px;background-color: #80C1CA; text-align: center">
            <div style="margin-left: 20px;">
                <img :src="businessInfo.bicon" alt="" width="100px" height="100px" style="border-radius: 180px">
            </div>
            <h2>欢迎来到{{businessInfo.store.sname}}!</h2>
            <p>美味好物,任君挑选</p>
        </div>




        <div class="list_model" style="width: 100%">
            <div class="goods_con clearfix" style="text-align: center">
                <ul class="goods_list fl" style="padding-left: 230px; width:100%;" >
                    <li v-for="(g,i) in storeGoodsListArr" :src= "g.img" :name="g.gname"  :sprice= "g.sprice":id="g.id" @click="detail(g.id)">
                        <h4><a>{{g.gname}}</a></h4>
                        <a><img :src="g.img"></a>
                        <div class="price" style="text-align: center; font-size:15px; font-weight: bolder; color: red">{{g.sprice}}￥</div>
                    </li>
                </ul>
            </div>
        </div>



</div>
<script>
    var app = new Vue({
        el:"#app",
        data:{
            storeGoodsListArr:[],
            businessInfo:{}
        },
        methods:{
            goBack:function(){
                $.get("/cai/consumer/businessLogin",function (backData){
                    if(backData.code == 2){
                        window.location.href = "/cai/index.html";
                    }else {
                        window.location.href = "/cai/indexTwo.html";
                    }}
                );
            },
            myOrder:function(){
                $.get("/cai/consumer/businessLogin",function (backData){
                    if(backData.code == 2){
                        if(confirm("还未登录，请先进行登录")){
                            window.location.href = "/cai/userLogin.html";
                        }
                    }else {
                        window.location.href = "/cai/userOrder.html"
                    }}
                );
            },
            userRegister:function(){
                $.get("/cai/consumer/businessLogin",function (backData){
                    if(backData.code == 2){
                        window.location.href = "/cai/userRegister.html";
                    }else {
                        app.$notify.error({
                            title: '错误提示',
                            message: '您已经成功注册，请勿重复注册'
                        });
                    }}
                );
            },
            userLogin:function(){
                $.get("/cai/consumer/businessLogin",function (backData){
                    if(backData.code == 2){
                        window.location.href = "/cai/userLogin.html";
                    }else {
                        app.$notify.error({
                            title: '错误提示',
                            message: '您已经成功登录，请勿重复登录'
                        });
                    }}
                );
            },
            message:function(){
                $.get("/cai/consumer/businessLogin",function (backData){
                    if(backData.code == 2){
                        if(confirm("还未登录，请先进行登录")){
                            window.location.href = "/cai/userLogin.html";
                        }
                    }else {
                        window.location.href = "/cai/reception.html"
                    }}
                );
            },
            myShop:function(){
                $.get("/cai/consumer/businessLogin",function (backData){
                    if(backData.code == 2){
                        if(confirm("还未登录，请先进行登录")){
                            window.location.href = "/cai/userLogin.html";
                        }
                    }else {
                        window.location.href = "/cai/shop.html";
                    }}
                );
            },
            isLogin:function(){
                $.get("/cai/consumer/businessLogin",function (backData){
                        if(backData.code == 2){
                            if(confirm("还未登录，请先进行登录")){
                                window.location.href = "/cai/userLogin.html";
                            }
                        }else {
                            window.location.href = "/cai/mineInfo.html";
                        }
                    }
                );
            },
            detail:function(a){
                window.location.href="/cai/detail.html?id="+a;
            },
            login: function () {
                window.location.href = "/cai/userLogin.html";
            },
            register:function () {
                window.location.href = "/cai/userRegister.html";
            },
            business:function () {
                $.get("/cai/consumer/businessLogin",function (backData) {
                    if(backData.code == 1){
                        window.location.href = "/cai/businessMain.html";
                    }else if(backData.code == 3){
                        window.location.href = "/cai/businessRegister.html";
                    }else{
                        if(confirm("还未登录，请先进行登录")){
                            window.location.href = "/cai/userLogin.html";
                        }
                    }
                });
            }

        }
    });
    window.onload = function () {
        var url = location.search;
        var id = JSON.parse(window.decodeURIComponent(url.split("=")[1]));
        console.log(id);
        $.get("/cai/goStore/list/"+id,function (backData) {
            app.storeGoodsListArr = backData.data.storeGoods;
            app.businessInfo = backData.data.businessInfo;
        })
    };

</script>

</body>
</html>